package exam.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/4/3 19:39
 * @since JDK 1.8
 */
@Service
public class MyEventService {

    @Autowired
    private ApplicationContext applicationContext;

    public void addEvent(String eventName) {
        // 发布事件
        MyEvent event = new MyEvent(this, eventName);
        applicationContext.publishEvent(event);
    }
}
